package com.chapter10.static_.details;

public class static_detail1 {

    //类变量是该类所有对象共享的，而实例对象是独享的
    public static int number;
    private String name;

    public static void main(String[] args) {
        static_detail1 sd = new static_detail1();
        static_detail1 sd2 = new static_detail1();
        static_detail1 sd3 = new static_detail1();

        sd.number = 100;

        //体现共享性.一次赋值，随时访问
        System.out.println(sd.number);
        System.out.println(sd2.number);

        //体现独享性:每个单独的对象的非静态成员无法共享
        sd.name = "name";
        System.out.println(sd2.name);

    }

}



